# include directory
#INCLUDE=../amx

!ifdef NDEBUG
  CDEBUG=-DNDEBUG
  LDEBUG=
!else
  CDEBUG=$(CCDEBUG)     #compiler-specific macro
  LDEBUG=$(LLDEBUG)     #compiler-specific macro
!endif

!ifdef BC31
  # Borland C++ 3.1
  # ---------------
  CDIR    =d:\programm\bc31
  MODEL   =l
  CC      =$(CDIR)\bin\bcc -c -d -w -m$(MODEL) $(CDEBUG)
  LINK    =$(CDIR)\bin\tlink /c /l /m /L$(CDIR)\lib $(LDEBUG)
  STARTOBJ=c0$(MODEL).obj
  LIBS    =c$(MODEL) math$(MODEL) emu
  DEFFILE =
  RCFILE  =
  CCDEBUG =-v
  LLDEBUG =-v
!endif

!ifdef BC31W
  # Borland C++ 3.1 & Winio (for Borland 5.2, use large model)
  # ----------------------------------------------------------
  CDIR    =d:\programm\bc31
  MODEL   =l
  CC      =$(CDIR)\bin\bcc -c -d -w -m$(MODEL) $(CDEBUG) -WS
  LINK    =$(CDIR)\bin\tlink /c/l /L$(CDIR)\lib $(LDEBUG) -Twe
  STARTOBJ=c0w$(MODEL)
  LIBS    =cw$(MODEL) math$(MODEL) emu import
  DEFFILE =sc
  RCFILE  =
  CCDEBUG =-v
  LLDEBUG =-v
!endif

!ifdef BC55
  # Borland C++ 5.5 (CBuilder 5)
  # ----------------------------
  CDIR    =d:\programm\cbuild~1
  CC      =$(CDIR)\bin\bcc32 -c -q -tWC -w $(CDEBUG)
  LINK    =$(CDIR)\bin\ilink32 -q -Tpe -L$(CDIR)\lib $(LDEBUG)
  STARTOBJ=c0x32.obj
  LIBS    =cw32 import32
  DEFFILE =
  RCFILE  =
  CCDEBUG =-v
  LLDEBUG =-v
!endif

!ifdef MSC6
  # Microsoft C 6.0 (16-bit), not Visual C/C++ 6.0, the old compiler from 1990
  # ------------------------
  MODEL=L
  CC=cl -c -A$(MODEL) -Ocls -qc -W4 -nologo
  LINK=link /NOE /NOD /NOLOGO /CO /ST:4096
  STARTOBJ=
  LIBS=$(MODEL)libce.lib
  RCFILE  =
  CCDEBUG =-Zi
  LLDEBUG =/CO
!endif

!ifdef MSVC
  # Microsoft Visual C/C++ 6.0 (32-bit)
  # -----------------------------------
  CC=cl -c -Os -W4 -nologo
  LINK=link /NOE /NOD /NOLOGO
  STARTOBJ=
  LIBS=
  RCFILE  =
  CCDEBUG =-Zi
  LLDEBUG =/CO
!endif

!ifdef LCC
  # LCC-Win32, by Jacob Navia
  # ---------
  CDIR    =e:\lcc
  CC      =$(CDIR)\bin\lcc -A -O -unused $(CDEBUG)
  LINK    =$(CDIR)\bin\lcclnk -L$(CDIR)\lib $(LDEBUG) -o $@ -x
  STARTOBJ=
  LIBS    =
  DEFFILE =
  RCFILE  =
  CCDEBUG =-g5
  LLDEBUG =     #the default of LCC is to include symbols, there is an option to strip them
!endif

!ifdef GCC
  # GCC (for Linux), see also specific makefile.linux
  # ---------------
  CC      =gcc
  CFLAGS  =-I$(INCLUDE) -I../linux -DLINUX -g
  LINK    =gcc
  LINKFLAGS=
  CCDEBUG =
  LLDEBUG =
  objs=sc1.o sc2.o sc3.o sc4.o sc5.o sc6.o sc7.o sclist.o scvars.o

  %.o : %.c sc.h ;
  	$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<

  %.scp : %.scp scpack ;
        ..\scpack $< $@

  sc:	$(OBJS)
  	$(LINK) $(LINKFLAGS) $(OBJS) -o $(TARGET)
!endif

!ifndef STARTOBJ        #this is the default
  WCC = 1
  # Watcom C/C++ 11.0 (see also note on using an alternative LINK command line)
  # -----------------
  CC      =wcc386 -w4 -osf+ -bt=nt $(CDEBUG) -3s -mf -zq
  LINK    =wlink $(LDEBUG) NAME sc.exe SYS nt op m
  STARTOBJ=
  LIBS    =
  RCFILE  =
  CCDEBUG =/d2 /hc
  LLDEBUG =d codeview op cvpack
!endif


#
# Inference rules
#
.c.obj :
  $(CC) $*.c

.sch.scp :
  ..\scpack $*.sch $*.scp

sc.exe : sc1.obj sc2.obj sc3.obj sc4.obj sc5.obj sc6.obj sc7.obj sclist.obj scvars.obj scexpand.obj
  !ifdef WCC
    #for Watcom C/C++ 11.0 use:
    $(LINK) FIL sc1.obj,sc2.obj,sc3.obj,sc4.obj,sc5.obj,sc6.obj,sc7.obj,sclist.obj,scvars.obj,scexpand.obj
  !else
    !ifdef LCC
      $(LINK) $(STARTOBJ) sc1.obj sc2.obj sc3.obj sc4.obj sc5.obj sc6.obj sc7.obj sclist.obj scvars.obj scexpand.obj
    !else
      #all other compilers use the syntax below
      $(LINK) $(STARTOBJ) sc1 sc2 sc3 sc4 sc5 sc6 sc7 sclist scvars scexpand,sc,sc,$(LIBS),$(DEFFILE)
    !endif
  !endif

sc1.obj : sc1.c sc.h

sc2.obj : sc2.c sc.h

sc3.obj : sc3.c sc.h

sc4.obj : sc4.c sc.h

sc5.obj : sc5.c sc5.scp sc.h

sc6.obj : sc6.c sc.h

sc7.obj : sc7.c sc7.scp sc.h

sclist.obj : sclist.c sc.h

scvars.obj : scvars.c sc.h

scexpand.obj : scexpand.c sc.h

# the .SCH files are the same as the .SCP files (as SCPACK changes files "in
# place"). The different extensions were chosen to make MAKE happy. So to get
# a .SCH file from a .SCP file, simply copy it.

sc5.scp : sc5.sch

sc7.scp : sc7.sch

